import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MaterialInfoVO, MaterialInfoForm, MaterialInfoQuery } from '@/api/agriculture/materialInfo/types';

/**
 * 查询农资信息列表
 * @param query
 * @returns {*}
 */

export const listMaterialInfo = (query?: MaterialInfoQuery): AxiosPromise<MaterialInfoVO[]> => {
  return request({
    url: '/agriculture/materialInfo/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询农资信息详细
 * @param materialId
 */
export const getMaterialInfo = (materialId: string | number): AxiosPromise<MaterialInfoVO> => {
  return request({
    url: '/agriculture/materialInfo/' + materialId,
    method: 'get'
  });
};

/**
 * 新增农资信息
 * @param data
 */
export const addMaterialInfo = (data: MaterialInfoForm) => {
  return request({
    url: '/agriculture/materialInfo',
    method: 'post',
    data: data
  });
};

/**
 * 修改农资信息
 * @param data
 */
export const updateMaterialInfo = (data: MaterialInfoForm) => {
  return request({
    url: '/agriculture/materialInfo',
    method: 'put',
    data: data
  });
};

/**
 * 删除农资信息
 * @param materialId
 */
export const delMaterialInfo = (materialId: string | number | Array<string | number>) => {
  return request({
    url: '/agriculture/materialInfo/' + materialId,
    method: 'delete'
  });
};
